package com.etc.service;

import com.etc.dao.AdminsDao;
import com.etc.entity.Admins;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminsDao adminsDao;

    @Override
    public Admins queryByAdmin(Integer admin_no) {
        return adminsDao.queryByAdmin(admin_no);
    }

    @Override
    public boolean deleteByAdmin(Integer admin_no) {
        int n = adminsDao.deleteByAdmin(admin_no);
        return n > 0;
    }

    @Override
    public boolean register(Admins admins) {
        int n = adminsDao.register(admins);
        return n > 0;
    }

    @Override
    public boolean updateByAdmin(Admins admins) {
        int n = adminsDao.updateByAdmin(admins);
        return n > 0;
    }

    @Override
    public Admins login(String admin_acount, String admin_password) {
        return adminsDao.login(admin_acount, admin_password);
    }

    @Override
    public PageInfo<Admins> queryAll(Integer pageNum,Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Admins> list=adminsDao.queryAll();
        PageInfo<Admins> pageInfo=new PageInfo<>(list);
        return pageInfo;
    }
}
